package com.ws.shop.action.front;


import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ws.shop.bean.Page;
import com.ws.shop.entity.Article;
import com.ws.shop.service.ArticleService;
import com.ws.shop.util.RequestUtil;


@Controller
@RequestMapping(value = "/help/*")
public class HelpAction extends BaseFrontAction{

	@Autowired
	private ArticleService articleService;
	@RequestMapping(value = "help.htm", method = RequestMethod.GET)
	public String help(HttpServletRequest request,Model model){
		int cid = 8; //帮助中心
		int state = 1;
		int pageno = RequestUtil.getIntParameter(request, Page.PAGE_NO, 1);
	    Page page = new Page(pageno, 10);
		articleService.getArticlesByCid(page, cid, state);
        model.addAttribute("page", page);
		return "help";
	}
	
	@RequestMapping(value = "helpdetail.htm", method = RequestMethod.GET)
	public String helpdetail(HttpServletRequest request,Model model){
		int id = RequestUtil.getIntParameter(request, "id", -1);//ID
		Article article = articleService.findArticleById(id);
		model.addAttribute("article", article);
		return "helpdetail";
	}
}
